import React from 'react'
// ===================================================================== Temp
import FormModal from '#cpt/temp/FormModal'
import Table from '#cpt/temp/Table'
// ===================================================================== global declare
// ===================================================================== Declare
const { $http, $fn } = window
// ===================================================================== Lazy
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		formData:[
			{ type: 'cpt',	component:() => <div className='fx w'>
				<span style={{width: 71}}>现有备注:</span>
				<div className='ex fx' style={{margin: '0 -10px'}}>
					{ Table.call(this, {isIndex: 1}) }
				</div>
			</div>  },
			{ label: '新备注:',		name: 'remark', 	type: 'textarea',	full:true,	required:true },
		]
	}
	
	// 表单
	cols = [
		{ title: '备注',				dataIndex: 'remark', 		width:300 },
		{ title: '操作人', 			dataIndex: 'user', 			width:100 },
		{ title: '操作时间',			dataIndex: 'date', 			...$fn.table.time }
	]
	
	fetch = () => $http.pull(null, 'qc-data/info', {param:this.submit}).then(({remark}) => {
		const data = remark.map((v, i) => ({index: i, ...v}))
		this.setState({data})
	})
	
	open = uuid => {
		this.submit = {uuid}
		this.fetch()
		this.modal.open({ formRef:this.formRef })
	}
	
	render(){
		return FormModal.call(this,{ title:'备注', width:700, api: 'qc-data/edit', labelWidth:'s5', enter: false })
	}
}

export default Index